package org.platform.processor.diagnose.job;

import com.mc.mic.core.log.bus.BusLogPusher;
import com.mc.mic.core.log.frame.LogBo;
import org.platform.constant.LogType;
import org.platform.mo.bussmo.log.DiagnoseTestStepMqBO;
import org.platform.mo.csmo.common.FD_DiagnoseTestStep;
import org.platform.mo.db.FdDiagnoseTestStep;
import org.platform.tool.util.BeansUtils;
import org.quartz.InterruptableJob;
import org.quartz.JobExecutionContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 推送测试步骤到客服端
 *
 * @author FengJie
 * @date 2018/8/31
 */
@Component
public class PromoteTestStepJob implements InterruptableJob {
    public static final String DATA_KEY = "testStep";

    @Autowired
    private BusLogPusher mqLog;

    @Override
    public void interrupt() {

    }

    @Override
    public void execute(JobExecutionContext context) {
        List<FdDiagnoseTestStep> list = (List<FdDiagnoseTestStep>) context.getMergedJobDataMap().get(DATA_KEY);
        List<FD_DiagnoseTestStep> testStepList = BeansUtils.copyListProperties(list, FD_DiagnoseTestStep.class);
        mqLog.log(new LogBo<>(LogType.TEST_STEP, new DiagnoseTestStepMqBO(testStepList)));

    }
}
